package ru.home.documentmanager.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import ru.home.documentmanager.dao.UserDAO;
import ru.home.documentmanager.model.User;
import ru.home.documentmanager.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    public UserDAO userDAO;

    @Override
    @Transactional
    public void save(User object) {
        userDAO.save(object);
    }

    @Override
    @Transactional
    public void update(User object) {
        userDAO.update(object);
    }

    @Override
    @Transactional
    public void saveOrUpdate(User object) {
        userDAO.saveOrUpdate(object);
    }

    @Override
    @Transactional
    public void delete(User object) {
        userDAO.delete(object);
    }

    @Override
    @Transactional
    public List<User> find() {
        return userDAO.find();
    }

    @Override
    @Transactional
    public User find(long id) {
        return userDAO.find(id);
    }

    @Override
    @Transactional
    public User findByUsername(String username) {
        return userDAO.findByUsername(username);
    }

    @Override
    @Transactional
    public void initFiles(User user) {
        userDAO.initFiles(user);
    }

    @Override
    public void delete(long id) {
        userDAO.delete(id);
    }

}
